package zhoug.zui.banner;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;

/**
 * 图片轮播的ViewPager
 * @Author 35574
 * @Date 2020/9/18
 * @Description
 */
public class ZUIBannerViewPager extends ViewPager {
    private boolean scrollable = true;

    public ZUIBannerViewPager(@NonNull Context context) {
        super(context);
    }

    public ZUIBannerViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        return this.scrollable && super.onTouchEvent(ev);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return this.scrollable && super.onInterceptTouchEvent(ev);
    }

    public void setScrollable(boolean scrollable) {
        this.scrollable = scrollable;
    }

}
